<br />
<div id="total" style="font-style: italic; color: red;"></div>
<br />
<br />
<hr />
<br />
<?php
    if(isset($_REQUEST["key"]) == true)
    {
        include_once("template/DataProvider.php");
        $tenSP = $_REQUEST["key"];
        $from = $_REQUEST["from"];
        $to = $_REQUEST["to"];
        $t = 1;
        $query = "
        SELECT * FROM sanpham s, nguoidung nd 
        WHERE nd.MaND = s.MaND 
        AND s.TenSP LIKE '%".$tenSP."%' 
        AND s.GiaSP BETWEEN ".$from." AND ".$to."
        ";
        $result = DataProvider::ExecuteQuery($query);
        while($row = mysql_fetch_array($result))
	   {
	        include("templateSanPham.php"); 
            $t++;
	   }
       ?>
        <!-- input tạm lấy dữ liệu tổng số sp -->
        <div id="temp">
        <input  type="text" value="Có Tổng Cộng -- <?php echo $t - 1 ; ?> -- Sản Phẩm Thỏa Yêu Cầu" id="total_"/>
        </div>
        
        <?php  
    }
    else
        header("location:trangchu.php");
?>



<script type="text/javascript" >
        //chép dữ liệu vào div có id là total
        var vaNode = document.getElementById("total_");
		var vitriNode = document.getElementById("total");
		var divNode = document.createElement("div");
		vitriNode.appendChild(divNode);
		var textNode = document.createTextNode(vaNode.value);
		divNode.appendChild(textNode);
        
        //remove temp
        var element = document.getElementById("temp");
        if ( element.hasChildNodes() )
        {
            while ( element.childNodes.length >= 0 )
            {
            element.removeChild( element.firstChild );       
            }
        }
        

</script>